User-defined

New user-defined variables and functions of one through five variables may be declared and used anywhere, including on the plot command itself.

User-defined function syntax:

     <func-name>( <dummy1> {,<dummy2>} ... {,<dummy5>} ) = <expression>

where <expression> is defined in terms of <dummy1> through <dummy5>.

User-defined variable syntax:

     <variable-name> = <constant-expression>

Examples:

     w = 2
     q = floor(tan(pi/2 - 0.1))
     f(x) = sin(w*x)
     sinc(x) = sin(pi*x)/(pi*x)
     delta(t) = (t == 0)
     ramp(t) = (t > 0) ? t : 0
     min(a,b) = (a < b) ? a : b
     comb(n,k) = n!/(k!*(n-k)!)
     len3d(x,y,z) = sqrt(x*x+y*y+z*z)
     plot f(x) = sin(x*a), a = 0.2, f(x), a = 0.4, f(x)

Note that the variable pi is already defined. But it is in no way magic; you may redefine it to be whatever you like.

Valid names are the same as in most programming languages: they must begin with a letter, but subsequent characters may be letters, digits, "$", or "_". Note, however, that the fit mechanism uses several variables with names that begin "FIT_". It is safest to avoid using such names. "FIT_LIMIT", however, is one that you may wish to redefine. See the documentation on fit for details.

See show functions, show variables, and fit.